package pojo;

import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class SysUser implements Serializable {

    private int id;
//    @NotEmpty(message = "账号不能为空")
    private String account; // 编号

//    @NotEmpty(message = "姓名不能为空")
    private String realName; // 姓名

//    @NotNull(message = "密码不能为空")
//    @Length(min = 6, max = 10, message = "密码长度在6到10位之间")
    private String password; // 密码
    private String phone; // 电话
//    @Past(message = "必须是一个过去的时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JSONField(format = "yyyy-MM-dd")
    private String birthday; // 出生日期
    private Integer age; // 年龄
    private Integer sex; // 性别
    private String address; // 地址
    private Integer roleId; // 角色id
    private Integer createUserId; // 创建人id
    private Date createdTime; // 创建时间
    private Integer updatedUserId; // 更新人id
    private String updatedTime; // 更新时间
    private String roleIdName; // 角色名称
    private Object idPicPath; // 身份证图片
    private Object workPicPath; // 工作证图片

    public SysUser() {
    }

    public SysUser(int id, String account, String realName, String password, String phone, String birthday, Integer sex, String address, Integer roleId, Integer createUserId, Date createdTime, Integer updatedUserId, String updatedTime) {
        this.id = id;
        this.account = account;
        this.realName = realName;
        this.password = password;
        this.phone = phone;
        this.birthday =birthday;
        this.sex = sex;
        this.address = address;
        this.roleId = roleId;
        this.createUserId = createUserId;
        this.createdTime = createdTime;
        this.updatedUserId = updatedUserId;
        this.updatedTime = updatedTime;
    }

    public Object getIdPicPath() {
        return idPicPath;
    }

    public void setIdPicPath(Object idPicPath) {
        this.idPicPath = idPicPath;
    }

    public Object getWorkPicPath() {
        return workPicPath;
    }

    public void setWorkPicPath(Object workPicPath) {
        this.workPicPath = workPicPath;
    }

    /**
     * 获取
     * @return id
     */
    public int getId() {
        return id;
    }

    /**
     * 设置
     * @param id
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * 获取
     * @return account
     */
    public String getAccount() {
        return account;
    }

    /**
     * 设置
     * @param account
     */
    public void setAccount(String account) {
        this.account = account;
    }

    /**
     * 获取
     * @return realName
     */
    public String getRealName() {
        return realName;
    }

    /**
     * 设置
     * @param realName
     */
    public void setRealName(String realName) {
        this.realName = realName;
    }

    /**
     * 获取
     * @return password
     */
    public String getPassword() {
        return password;
    }

    /**
     * 设置
     * @param password
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * 获取
     * @return phone
     */
    public String getPhone() {
        return phone;
    }

    /**
     * 设置
     * @param phone
     */
    public void setPhone(String phone) {
        this.phone = phone;
    }

    /**
     * 获取
     *
     * @return birthday
     */
    public String getBirthday() {
        return birthday;
    }

    /**
     * 设置
     * @param birthday
     */
    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    /**
     * 获取
     * @return age
     */
    public Integer getAge() {
        if(birthday != null){
            int age= Integer.parseInt(new SimpleDateFormat("yyyy").format(birthday));
            int yyyy = Integer.parseInt(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy")));
            this.age = yyyy - age;
        }
        return this.age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(Integer age) {
        this.age = age;
    }

    /**
     * 获取
     * @return sex
     */
    public Integer getSex() {
        return sex;
    }

    /**
     * 设置
     * @param sex
     */
    public void setSex(Integer sex) {
        this.sex = sex;
    }

    /**
     * 获取
     * @return address
     */
    public String getAddress() {
        return address;
    }

    /**
     * 设置
     * @param address
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * 获取
     * @return roleId
     */
    public Integer getRoleId() {
        return roleId;
    }

    /**
     * 设置
     * @param roleId
     */
    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    /**
     * 获取
     * @return createUserId
     */
    public Integer getCreateUserId() {
        return createUserId;
    }

    /**
     * 设置
     * @param createUserId
     */
    public void setCreateUserId(Integer createUserId) {
        this.createUserId = createUserId;
    }

    /**
     * 获取
     * @return createdTime
     */
    public Date getCreatedTime() {
        return createdTime;
    }

    /**
     * 设置
     * @param createdTime
     */
    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    /**
     * 获取
     * @return updatedUserId
     */
    public Integer getUpdatedUserId() {
        return updatedUserId;
    }

    /**
     * 设置
     * @param updatedUserId
     */
    public void setUpdatedUserId(Integer updatedUserId) {
        this.updatedUserId = updatedUserId;
    }

    /**
     * 获取
     * @return updatedTime
     */
    public String getUpdatedTime() {
        return updatedTime;
    }

    /**
     * 设置
     * @param updatedTime
     */
    public void setUpdatedTime(String updatedTime) {
        this.updatedTime = updatedTime;
    }

    /**
     * 获取
     * @return roleIdName
     */
    public String getRoleIdName() {
        return roleIdName;
    }

    /**
     * 设置
     * @param roleIdName
     */
    public void setRoleIdName(String roleIdName) {
        this.roleIdName = roleIdName;
    }

    @Override
    public String toString() {
        return "SysUser{" +
                "id=" + id +
                ", account='" + account + '\'' +
                ", realName='" + realName + '\'' +
                ", password='" + password + '\'' +
                ", phone='" + phone + '\'' +
                ", birthday=" + birthday +
                ", age=" + age +
                ", sex=" + sex +
                ", address='" + address + '\'' +
                ", roleId=" + roleId +
                ", createUserId=" + createUserId +
                ", createdTime=" + createdTime +
                ", updatedUserId=" + updatedUserId +
                ", updatedTime=" + updatedTime +
                ", roleIdName='" + roleIdName + '\'' +
                ", idPicPath='" + idPicPath + '\'' +
                ", workPicPath='" + workPicPath + '\'' +
                '}';
    }
}
